class_name BallStateShoot
extends BallState

const SHOOT_SPRITE_SCALE := 0.8
const SHOOT_HEIGHT := 5.0
const DURATION_SHOOT : = 1000
var time_since_shoot := 0.0

func _enter_tree() -> void:
	set_ball_animation_from_velocity()
	ball_sprite.scale.y = SHOOT_SPRITE_SCALE
	ball.height = SHOOT_HEIGHT
	time_since_shoot = Time.get_ticks_msec()
	shoot_particles.emitting = true
	GameEvent.impact_received(ball.position, true)
	
func _exit_tree() -> void:
	ball_sprite.scale.y = 1.0
	shoot_particles.emitting = false

func _process(delta: float) -> void:
	if Time.get_ticks_msec() - time_since_shoot > DURATION_SHOOT:
		state_transition(Ball.State.FREEFORM)
	else:
		move_and_bouness(delta)
